﻿dynamic class com.meychi.ascrypt.GUID
{
    static var counter: Number = 0;

    function GUID()
    {
    }

    static function create()
    {
        /*var __reg3 = (new Date()).getTime();
        var __reg2 = Math.random() * 1.79769e+308;
        var __reg1 = System.capabilities.serverString;
        return com.meychi.ascrypt.SHA1.calculate(__reg3 + __reg1 + __reg2 + com.meychi.ascrypt.GUID.counter++);
		*/
		var now = new Date();
		var dateStr:String = "";
		var year = now.getFullYear();
		var month = now.getMonth();
		var day = now.getDate();
		var hour = now.getHours();
		var minute = now.getMinutes();
		var second = now.getSeconds();
		var rand = Math.floor(Math.random() * 1000) + 1000;
		
		dateStr = year + addZero(month+1) + addZero(day) + addZero(hour) + addZero(minute) + addZero(second) + "_" + rand;
		
		return dateStr;
    }
	static function addZero(val:Number)
	{
		return (val<10)?"0"+val:""+val;
	}
}
